package czx.model;

// default package

import java.util.Date;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * 用户表
 */
@Entity
@Table(name = "tuser", uniqueConstraints = @UniqueConstraint(columnNames = "chname"))
public class Tuser implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String id;
	private String chname;
	private String password;
	private Date createdatetime;
	private Date modifydatetime;

	// Constructors

	/** default constructor */
	public Tuser() {
		this.id = UUID.randomUUID().toString();
		this.chname = "";
		this.password = "";
		this.createdatetime = new Date();
		this.modifydatetime = this.createdatetime;
	}

	/** full constructor */
	public Tuser(String id, String chname, String password, Date createdatetime, Date modifydatetime) {
		this.id = id;
		this.chname = chname;
		this.password = password;
		this.createdatetime = createdatetime;
		this.modifydatetime = modifydatetime;
	}

	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false, length = 36)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "chname", unique = true, nullable = false, length = 100)
	public String getChname() {
		return this.chname;
	}

	public void setChname(String chname) {
		this.chname = chname;
	}

	@Column(name = "password", nullable = false, length = 32)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "createdatetime", nullable = false, length = 19)
	public Date getCreatedatetime() {
		return this.createdatetime;
	}

	public void setCreatedatetime(Date createdatetime) {
		this.createdatetime = createdatetime;
	}

	@Column(name = "modifydatetime", nullable = false, length = 19)
	public Date getModifydatetime() {
		return this.modifydatetime;
	}

	public void setModifydatetime(Date modifydatetime) {
		this.modifydatetime = modifydatetime;
	}

	public void Validate() throws ValidateException {
		if (this.chname == "")
			throw new ValidateException("用户名不能为空");
	}
}